package com.neuedu.his.service;

import com.neuedu.his.dao.UserDao;
import com.neuedu.his.entity.User;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 项目：      his
 * 类名:       LoginService
 * 创建时间：  2020/12/24  14:04
 * 描述 :
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
public class LoginService  {

    private UserDao userDao = new UserDao();


    public User login(HttpServletRequest request){

        String username = request.getParameter("username");
        String password = request.getParameter("password");


        String sql = " select * from user where  username = ? and password = ? ";


        List<User> userList = userDao.selectList(sql, username, password);

        User user = null;
        if(userList != null && userList.size()>0){
            user = userList.get(0);

            request.getSession().setAttribute("user",user);
            user.setPassword(null);
        }



        return user;  //带着密码
    }










}
